package org.jivesoftware.smack;

import java.io.File;
import javax.net.SocketFactory;
import org.apache.harmony.javax.security.auth.callback.CallbackHandler;
import org.jivesoftware.smack.proxy.ProxyInfo;
import org.jivesoftware.smack.util.DNSUtil;
import org.jivesoftware.smack.util.DNSUtil.HostAddress;

public class ConnectionConfiguration
  implements Cloneable
{
  private CallbackHandler callbackHandler;
  private String capsNode;
  private boolean compressionEnabled;
  private boolean debuggerEnabled;
  private boolean expiredCertificatesCheckEnabled;
  private String host;
  private boolean isRosterVersioningAvailable;
  private String keystorePath;
  private String keystoreType;
  private boolean notMatchingDomainCheckEnabled;
  private String password;
  private String pkcs11Library;
  private int port;
  protected ProxyInfo proxy;
  private boolean reconnectionAllowed;
  private String resource;
  private boolean rosterLoadedAtLogin;
  private boolean saslAuthenticationEnabled;
  private SecurityMode securityMode;
  private boolean selfSignedCertificateEnabled;
  private boolean sendPresence;
  private String serviceName;
  private SocketFactory socketFactory;
  private String truststorePassword;
  private String truststorePath;
  private String truststoreType;
  private String username;
  private boolean verifyChainEnabled = false;
  private boolean verifyRootCAEnabled = false;

  public ConnectionConfiguration(String paramString)
  {
    this.selfSignedCertificateEnabled = false;
    this.expiredCertificatesCheckEnabled = false;
    this.notMatchingDomainCheckEnabled = false;
    this.isRosterVersioningAvailable = false;
    this.capsNode = null;
    this.compressionEnabled = false;
    this.saslAuthenticationEnabled = true;
    this.debuggerEnabled = Connection.DEBUG_ENABLED;
    this.reconnectionAllowed = true;
    this.sendPresence = true;
    this.rosterLoadedAtLogin = true;
    this.securityMode = SecurityMode.enabled;
    DNSUtil.HostAddress localHostAddress = DNSUtil.resolveXMPPDomain(paramString);
    init(localHostAddress.getHost(), localHostAddress.getPort(), paramString, ProxyInfo.forDefaultProxy());
  }

  public ConnectionConfiguration(String paramString, int paramInt)
  {
    this.selfSignedCertificateEnabled = false;
    this.expiredCertificatesCheckEnabled = false;
    this.notMatchingDomainCheckEnabled = false;
    this.isRosterVersioningAvailable = false;
    this.capsNode = null;
    this.compressionEnabled = false;
    this.saslAuthenticationEnabled = true;
    this.debuggerEnabled = Connection.DEBUG_ENABLED;
    this.reconnectionAllowed = true;
    this.sendPresence = true;
    this.rosterLoadedAtLogin = true;
    this.securityMode = SecurityMode.enabled;
    init(paramString, paramInt, paramString, ProxyInfo.forDefaultProxy());
  }

  public ConnectionConfiguration(String paramString1, int paramInt, String paramString2)
  {
    this.selfSignedCertificateEnabled = false;
    this.expiredCertificatesCheckEnabled = false;
    this.notMatchingDomainCheckEnabled = false;
    this.isRosterVersioningAvailable = false;
    this.capsNode = null;
    this.compressionEnabled = false;
    this.saslAuthenticationEnabled = true;
    this.debuggerEnabled = Connection.DEBUG_ENABLED;
    this.reconnectionAllowed = true;
    this.sendPresence = true;
    this.rosterLoadedAtLogin = true;
    this.securityMode = SecurityMode.enabled;
    init(paramString1, paramInt, paramString2, ProxyInfo.forDefaultProxy());
  }

  public ConnectionConfiguration(String paramString1, int paramInt, String paramString2, ProxyInfo paramProxyInfo)
  {
    this.selfSignedCertificateEnabled = false;
    this.expiredCertificatesCheckEnabled = false;
    this.notMatchingDomainCheckEnabled = false;
    this.isRosterVersioningAvailable = false;
    this.capsNode = null;
    this.compressionEnabled = false;
    this.saslAuthenticationEnabled = true;
    this.debuggerEnabled = Connection.DEBUG_ENABLED;
    this.reconnectionAllowed = true;
    this.sendPresence = true;
    this.rosterLoadedAtLogin = true;
    this.securityMode = SecurityMode.enabled;
    init(paramString1, paramInt, paramString2, paramProxyInfo);
  }

  public ConnectionConfiguration(String paramString, int paramInt, ProxyInfo paramProxyInfo)
  {
    this.selfSignedCertificateEnabled = false;
    this.expiredCertificatesCheckEnabled = false;
    this.notMatchingDomainCheckEnabled = false;
    this.isRosterVersioningAvailable = false;
    this.capsNode = null;
    this.compressionEnabled = false;
    this.saslAuthenticationEnabled = true;
    this.debuggerEnabled = Connection.DEBUG_ENABLED;
    this.reconnectionAllowed = true;
    this.sendPresence = true;
    this.rosterLoadedAtLogin = true;
    this.securityMode = SecurityMode.enabled;
    init(paramString, paramInt, paramString, paramProxyInfo);
  }

  public ConnectionConfiguration(String paramString, ProxyInfo paramProxyInfo)
  {
    this.selfSignedCertificateEnabled = false;
    this.expiredCertificatesCheckEnabled = false;
    this.notMatchingDomainCheckEnabled = false;
    this.isRosterVersioningAvailable = false;
    this.capsNode = null;
    this.compressionEnabled = false;
    this.saslAuthenticationEnabled = true;
    this.debuggerEnabled = Connection.DEBUG_ENABLED;
    this.reconnectionAllowed = true;
    this.sendPresence = true;
    this.rosterLoadedAtLogin = true;
    this.securityMode = SecurityMode.enabled;
    DNSUtil.HostAddress localHostAddress = DNSUtil.resolveXMPPDomain(paramString);
    init(localHostAddress.getHost(), localHostAddress.getPort(), paramString, paramProxyInfo);
  }

  private void init(String paramString1, int paramInt, String paramString2, ProxyInfo paramProxyInfo)
  {
    this.host = paramString1;
    this.port = paramInt;
    this.serviceName = paramString2;
    this.proxy = paramProxyInfo;
    String str = System.getProperty("java.home");
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append(str).append(File.separator).append("lib");
    localStringBuilder.append(File.separator).append("security");
    localStringBuilder.append(File.separator).append("cacerts");
    this.truststorePath = localStringBuilder.toString();
    this.truststoreType = "jks";
    this.truststorePassword = "changeit";
    this.keystorePath = System.getProperty("javax.net.ssl.keyStore");
    this.keystoreType = "jks";
    this.pkcs11Library = "pkcs11.config";
    this.socketFactory = paramProxyInfo.getSocketFactory();
  }

  public CallbackHandler getCallbackHandler()
  {
    return this.callbackHandler;
  }

  String getCapsNode()
  {
    return this.capsNode;
  }

  public String getHost()
  {
    return this.host;
  }

  public String getKeystorePath()
  {
    return this.keystorePath;
  }

  public String getKeystoreType()
  {
    return this.keystoreType;
  }

  public String getPKCS11Library()
  {
    return this.pkcs11Library;
  }

  String getPassword()
  {
    return this.password;
  }

  public int getPort()
  {
    return this.port;
  }

  String getResource()
  {
    return this.resource;
  }

  public SecurityMode getSecurityMode()
  {
    return this.securityMode;
  }

  public String getServiceName()
  {
    return this.serviceName;
  }

  public SocketFactory getSocketFactory()
  {
    return this.socketFactory;
  }

  public String getTruststorePassword()
  {
    return this.truststorePassword;
  }

  public String getTruststorePath()
  {
    return this.truststorePath;
  }

  public String getTruststoreType()
  {
    return this.truststoreType;
  }

  String getUsername()
  {
    return this.username;
  }

  public boolean isCompressionEnabled()
  {
    return this.compressionEnabled;
  }

  public boolean isDebuggerEnabled()
  {
    return this.debuggerEnabled;
  }

  public boolean isExpiredCertificatesCheckEnabled()
  {
    return this.expiredCertificatesCheckEnabled;
  }

  public boolean isNotMatchingDomainCheckEnabled()
  {
    return this.notMatchingDomainCheckEnabled;
  }

  public boolean isReconnectionAllowed()
  {
    return this.reconnectionAllowed;
  }

  public boolean isRosterLoadedAtLogin()
  {
    return this.rosterLoadedAtLogin;
  }

  boolean isRosterVersioningAvailable()
  {
    return this.isRosterVersioningAvailable;
  }

  public boolean isSASLAuthenticationEnabled()
  {
    return this.saslAuthenticationEnabled;
  }

  public boolean isSelfSignedCertificateEnabled()
  {
    return this.selfSignedCertificateEnabled;
  }

  boolean isSendPresence()
  {
    return this.sendPresence;
  }

  public boolean isVerifyChainEnabled()
  {
    return this.verifyChainEnabled;
  }

  public boolean isVerifyRootCAEnabled()
  {
    return this.verifyRootCAEnabled;
  }

  public void setCallbackHandler(CallbackHandler paramCallbackHandler)
  {
    this.callbackHandler = paramCallbackHandler;
  }

  void setCapsNode(String paramString)
  {
    this.capsNode = paramString;
  }

  public void setCompressionEnabled(boolean paramBoolean)
  {
    this.compressionEnabled = paramBoolean;
  }

  public void setDebuggerEnabled(boolean paramBoolean)
  {
    this.debuggerEnabled = paramBoolean;
  }

  public void setExpiredCertificatesCheckEnabled(boolean paramBoolean)
  {
    this.expiredCertificatesCheckEnabled = paramBoolean;
  }

  public void setKeystorePath(String paramString)
  {
    this.keystorePath = paramString;
  }

  public void setKeystoreType(String paramString)
  {
    this.keystoreType = paramString;
  }

  void setLoginInfo(String paramString1, String paramString2, String paramString3)
  {
    this.username = paramString1;
    this.password = paramString2;
    this.resource = paramString3;
  }

  public void setNotMatchingDomainCheckEnabled(boolean paramBoolean)
  {
    this.notMatchingDomainCheckEnabled = paramBoolean;
  }

  public void setPKCS11Library(String paramString)
  {
    this.pkcs11Library = paramString;
  }

  public void setReconnectionAllowed(boolean paramBoolean)
  {
    this.reconnectionAllowed = paramBoolean;
  }

  public void setRosterLoadedAtLogin(boolean paramBoolean)
  {
    this.rosterLoadedAtLogin = paramBoolean;
  }

  void setRosterVersioningAvailable(boolean paramBoolean)
  {
    this.isRosterVersioningAvailable = paramBoolean;
  }

  public void setSASLAuthenticationEnabled(boolean paramBoolean)
  {
    this.saslAuthenticationEnabled = paramBoolean;
  }

  public void setSecurityMode(SecurityMode paramSecurityMode)
  {
    this.securityMode = paramSecurityMode;
  }

  public void setSelfSignedCertificateEnabled(boolean paramBoolean)
  {
    this.selfSignedCertificateEnabled = paramBoolean;
  }

  public void setSendPresence(boolean paramBoolean)
  {
    this.sendPresence = paramBoolean;
  }

  public void setServiceName(String paramString)
  {
    this.serviceName = paramString;
  }

  public void setSocketFactory(SocketFactory paramSocketFactory)
  {
    this.socketFactory = paramSocketFactory;
  }

  public void setTruststorePassword(String paramString)
  {
    this.truststorePassword = paramString;
  }

  public void setTruststorePath(String paramString)
  {
    this.truststorePath = paramString;
  }

  public void setTruststoreType(String paramString)
  {
    this.truststoreType = paramString;
  }

  public void setVerifyChainEnabled(boolean paramBoolean)
  {
    this.verifyChainEnabled = paramBoolean;
  }

  public void setVerifyRootCAEnabled(boolean paramBoolean)
  {
    this.verifyRootCAEnabled = paramBoolean;
  }

  public static enum SecurityMode
  {
    static
    {
      enabled = new SecurityMode("enabled", 1);
      disabled = new SecurityMode("disabled", 2);
      SecurityMode[] arrayOfSecurityMode = new SecurityMode[3];
      arrayOfSecurityMode[0] = required;
      arrayOfSecurityMode[1] = enabled;
      arrayOfSecurityMode[2] = disabled;
      ENUM$VALUES = arrayOfSecurityMode;
    }
  }
}